#ifndef CImageTGA_____
#define CImageTGA_____

// Notes: currently this class only provides support for Image Type 2 and 3
// Type 2 = uncomp. true-color 24-bit
// Type 3 = uncomp. black-and-white 8-bit

typedef struct // 5 bytes
{
	unsigned short FirstEntryIndex;
	unsigned short Length;
	unsigned char Size;
} ColorMapSpec;

typedef struct // 10 bytes
{
	unsigned short XOrigin;
	unsigned short YOrigin;
	unsigned short Width;
	unsigned short Height;
	unsigned char PixelDepth;
	unsigned char Descriptor;	
} ImageSpec;

typedef struct // 18 bytes
{
	unsigned char IDLength;
	unsigned char ColorMapType;
	unsigned char ImageType;
	ColorMapSpec ColorMap;
	ImageSpec Image;
} TGAFileHeader;

//-----------------------------------------------------------------------------
class CImageTGA
//-----------------------------------------------------------------------------
{

  public:

	//-------------------------------------------------------------------------
	// members
	//-------------------------------------------------------------------------

	TGAFileHeader *m_pTGAFileHeader;
	unsigned char *m_pImageData;
	int			   m_nBytesPerPixel;
	int			   m_nTotalImageBytes;

	//-------------------------------------------------------------------------
	// member functions
	//-------------------------------------------------------------------------

	int Load(CString path);
	void ConvertRGBToGreyscale(float RedWeightFactor, float GreenWeightFactor, float BlueWeightFactor);
	int Save(CString path);
	void SetupUncomp24Bit(int nSize);
	void SetupUncomp8Bit(int nSize);

	//-------------------------------------------------------------------------
	// constructors
	//-------------------------------------------------------------------------
	
	CImageTGA();

	//-------------------------------------------------------------------------
	// constructors
	//-------------------------------------------------------------------------

	~CImageTGA();

};

#endif
